﻿@model GPS.ENTITYS.ViewModelDDTTN_KQTN
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Điểm học viên tốt nghiệp";
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/datepicker.js"></script>

<link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="~/Scripts/locales/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>


<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>
<script src="~/Scripts/moment.js"></script>

<link href="~/dist/css/bootstrap-select.css" rel="stylesheet" />
<script src="~/dist/js/bootstrap-select.js"></script>

<link href="~/Scripts/select2.css" rel="stylesheet" />
<link href="~/Scripts/select2.min.css" rel="stylesheet" />
<script src="~/Scripts/select2.js"></script>

<script>
    $(document).ready(function () {



        // load district by province when change in dropdownlist
        $("#DVGTVT_MA_dll").change(function () {
         //   alert($('#DVGTVT_MA_dll').val());
            $.ajax({
                url: '@Url.Action("getKH_MAs", "GPS_DiemTotNghiep")',
                type: 'post',
                data: {
                    ma_DVGT: $('#DVGTVT_MA_dll').val()
                }
            }).done(function (response) {
             //   // update district by province
               
             //   var a = '<option value></option>' + response.split('#')[0];   // defaut value
             ////   alert(response.split('#').length);
             //   $("#KH_MA_ddl").html(a);
             //   $('#KH_MA_ddl').selectpicker('refresh');

                if (response.split('#').length > 1)
                {
                    var b = '<option value></option>' + response.split('#')[1];   // defaut value
                    $("#SO_QD_TN_dll").html(b);
                }
                else
                {
                    var b = '<option value></option>'; // defaut value
                    $("#SO_QD_TN_dll").html(b);
                }
           

            });
        });

        var pageSize = 20;
        var optionListUrl = '@Url.Action("Select2KH_MA_TraCuu", "GPS_Ajax")';

        $('#KH_MA_ddl').select2(
                {
                    ajax: {
                        delay: 50,
                        url: optionListUrl,
                        dataType: 'json',

                        data: function (params) {
                            /// params.page = params.page || 1;
                            return {
                                searchTerm: params.term,
                                dvgtvt_ma: $("#DVGTVT_MA_dll").val()
                                //pageNumber: params.page results: JSON.parse(data)
                            };
                        },
                        processResults: function (data, params) {

                            return {
                                results: data.Results
                            };
                        }
                    },
                    placeholder: "-- Chọn khóa học --",
                    minimumInputLength: 2,
                    allowClear: true,
                    language: { inputTooShort: function () { return 'Nhập lớn hơn 2 ký tự để tìm kiếm khóa học'; } }
                });

    });
</script>

<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">Tra cứu Thông tin Điểm tốt nghiệp học viên</h3>
    <div class="row">
        @using (Html.BeginForm("Search", "GPS_DiemTotNghiep", FormMethod.Get))
        {

            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều Kiện Tìm Kiếm</legend>

                    <div class="row criteria_search">
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Đơn vị đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.pDVGTVT_MA, (SelectList)ViewBag.DVGTVT_MAs, string.Empty, new { @class = "form-control", @id = "DVGTVT_MA_dll" })
                            </div>
                            <div class="col-md-2 control-label">
                                Khóa đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.pKH_MA, (SelectList)ViewBag.KH_MAs, string.Empty, new { @title = "Vui lòng chọn khóa học...", @id = "KH_MA_ddl", @style = "font-weight:bold;width:300px" })
                            </div>
                        </div>
                        <div class="row margin-top-05">

                            <div class="col-md-2 control-label">
                                Mã học viên
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_MA, new { @class = "form-control" })
                            </div>
                            <div class="col-md-2 control-label">
                                Họ tên
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_HOTEN, new { @class = "form-control" })
                            </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Số CMND
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_CMND, new { @class = "form-control" })
                            </div>

                            <div class="col-md-2 control-label">
                                Hạng đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.pHANG_DT, (SelectList)ViewBag.HANGDT_MAs, string.Empty, new { @class = "form-control", @id = "HANGDT_MA_dll" })
                            </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Tên khóa Tốt nghiệp
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.pSO_QD_TN, (SelectList)ViewBag.DTTN_QDs, string.Empty, new { @class = "form-control", @id = "SO_QD_TN_dll" })
                            </div>


                        </div>
                        <div class="row">
                            <div class="col-md-2 control-label">
                                Ngày Kết quả TN từ ngày
                            </div>
                            <div class="col-md-4">

                                @Html.TextBoxFor(model => model.pNGAY_KQTN_TUNGAY, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })
                            </div>

                            <div class="col-md-2 control-label">
                                Ngày Kết quả TN đến ngày
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pNGAY_KQTN_DENNGAY, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })

                            </div>
                        </div>

                    </div>

                    <div class="row margin-top-05 btn_search">
                        <button type="submit" class="btn btn-warning btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                    </div>
                </fieldset>
            </div>
        }
        <br />
        <div id="dialog"></div>
        <div class="row">
            <fieldset class="fs_body">
                <legend class="head_title">Kết quả tìm kiếm</legend>

                <div class="row divbtnFielset">
                    <div style="float: left;">
                       </div>
                    <div style="float: right;">
                        <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                    </div>
                </div>

                <div class="row" style="clear:both; padding: 5px 0;">
                    <table class="table table-hover table-bordered table-condensed" id="tabledata">
                        <tr>
                            <th>
                                STT
                            </th>
                            <th>
                                Tên học viên
                            </th>

                            <th style="width:200px">
                                Đơn vị GTVT
                            </th>
                            <th>
                                Khóa học
                            </th>
                            <th>
                                Giới tính
                            </th>
                            <th>
                                Ngày sinh
                            </th>
                            <th>
                                Ngày KQTN
                            </th>
                            <th>
                                Điểm TNLT
                            </th>
                            <th>
                                Điểm TNTH
                            </th>
                            <th>
                                Điểm TNTD
                            </th>
                            <th>
                                Điểm TNCC
                            </th>
                            <th>
                                Điểm TBC
                            </th>
                            <th>
                                Điểm TNTB
                            </th>
                            <th>
                                Điểm TKKH
                            </th>
                            @*<th>
                                    Người nhập
                                </th>*@
                            <th></th>
                        </tr>
                        @{
                            if (Model.SearchResults != null)
                            {
                                var i = 0;
                                var _display = "block";
                                foreach (var item in Model.SearchResults)
                                {

                                    if (item.ID != null)
                                    {

                                        _display = "block";
                                    }
                                    else
                                    {

                                        _display = "none";
                                    }

                                    <tr>
                                        <td>
                                            @(i + 1)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.HV_HO_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.HV_DVGTVT_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.HV_KH_TEN)
                                        </td>
                                        <td>
                                            @{
                                    if (item.HV_GIOITINH == "F")
                                    {
                                        @Html.Raw("Nữ")
                                    }
                                    else
                                    {
                                        @Html.Raw("Nam")
                                    }
                                            }
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.HV_NGAYSINH))

                                         
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_NGAYTN))
                                           
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_LT))
                                            
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TH))
                                          
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TD))
                                            
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TD))
                                           
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TBC))
                                           
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TB))
                                           
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTTN_KQTN_TKKH))
                                           
                                        </td>

                                        <td align="left">
                                            <div>
                                                @*<a href="@Url.Action("Detail", "GPS_DiemTotNghiep", new { id1 = item.DTTN_KQTN_DVGTVT_MA, id2 = item.DTTN_KQTN_KH_MA, id3 = item.DTTN_KQTN_KH_LOP_MA, id4 = item.DTTN_KQTN_HV_MA })" data-modal="">
                                                        <img src="@Url.Content("~/fonts/grid-view-icon.png")" title="Xem chi tiết" />
                                                    </a>*@
                                                

                                            </div>
                                        </td>
                                    </tr>
                                    i++;
                                }
                            }
                        }

                    </table>
                </div>

                <div class="pagination-sm row" style="clear:both; padding: 5px 0;">
                    @Html.PagedListPager(Model.SearchResults, page => Url.Action("Search", new
   {
       page,
       Model.pDVGTVT_MA,
       Model.pKH_MA,
       Model.pKH_LOP_MA,
       Model.pHV_MA,
       Model.pHV_HOTEN,
       Model.pHV_CMND,
       Model.pHANG_DT,
       Model.pSO_QD_TN,
       Model.pNGAY_KQTN_TUNGAY,
       Model.pNGAY_KQTN_DENNGAY
   }))
                </div>
            </fieldset>

        </div>
    </div>
</div>

<div id="wait" style="display: none; position:absolute; top: 10%; right: 10%; padding: 2px; z-index: 99999">
    <img src="~/fonts/images/loading16.gif" width="65" height="65" />
</div>



<!-- delete modal placeholder-->
<div id='deleteModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='deleteModalContent'></div>
        </div>
    </div>
</div>

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>


@section Scripts {
    @Scripts.Render("~/bundles/modalform")
}



@*var toasts = [
        new Toast('error', 'toast-bottom-full-width', 'This is positioned in the bottom full width. You can also style the icon any way you like.'),
        new Toast('info', 'toast-top-full-width', 'top full width'),
        new Toast('warning', 'toast-top-left', 'This is positioned in the top left. You can also style the icon any way you like.'),
        new Toast('success', 'toast-top-right', 'top right'),
        new Toast('warning', 'toast-bottom-right', 'bottom right'),
        new Toast('error', 'toast-bottom-left', 'bottom left')
    ];*@
<script type="text/javascript">

    $("#pNGAY_KQTN_TUNGAY").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });
    $("#pNGAY_KQTN_TUNGAY").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    $("#pNGAY_KQTN_DENNGAY").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });
    $("#pNGAY_KQTN_DENNGAY").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });


 

</script>

<script type="text/javascript">
    toastr.options = {
        "debug": false,
        "positionClass": "toast-bottom-right",
        "fadeIn": 500,
        "fadeOut": 2000,
        "timeOut": 1000,
        "extendedTimeOut": 1000

    }


    $(document).tooltip();


    $.ajaxSetup({ cache: false });

    $("a[data-modal]").on("click", function (e) {
        // alert(this.href);
        $('#myModalContent').load(this.href, function () {
            // alert(this.href);

            $('#myModal').modal({
                /*backdrop: 'static',*/
                keyboard: true
            }, 'show');

            bindForm(this);
        });

        return false;
    });

    function bindForm(dialog) {

        $('form', dialog).submit(function () {
            //  alert(dialog);
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    //  alert(result.success);
                    if (result.success) {

                        $('#myModal').modal('hide');
                        //Refresh
                        location.reload();
                        //$('#replacetarget').load(result.url); //  Load data from the server and place the returned HTML into the matched element
                    } else {
                        $('#myModalContent').html(result);
                        bindForm(dialog);
                    }
                }
            });
            return false;
        });
    }


</script>

<script type="text/javascript">

    //$('.selectpicker').selectpicker({
    //    liveSearch: true,
    //    showSubtext: true
    //});


</script>


